
import * as THREE from 'three';
import ControllerState from '../ControllerState';

export default async function sceneRem(s: ControllerState, object3D?: THREE.Object3D | string) {
    if (!object3D) return;
    if (typeof object3D === 'string') {
        const element = s.elementMap.get(object3D);
        if (element) {
            s.scene?.remove(element.object3D);
            s.elementMap.delete(object3D)
        }
    } else {
        if (object3D) {
            s.scene?.remove(object3D);
            s.elementMap.delete(object3D.uuid);
        }
    }
    s.elementMap = new Map(s.elementMap);
}

